﻿using System;
class PresenceOfSum
{
    static void Main()
    {
        int lenght;
        int givenSum;
        int currentSum = 0;
        int index = 0;
        Console.Write("please enter the lenght of array: ");
        while (true)
        {
            try
            {
                lenght = int.Parse(Console.ReadLine());
                break;
            }
            catch (Exception)
            {
                Console.Write("Please re-enter lenght:");
            }
        }
        int[] theArray;
        theArray = new int[lenght];
        for (int i = 0; i < lenght; i++)
        {
            Console.Write("Please enter the {0} element of array: ", i);
            while (true)
            {
                try
                {
                    theArray[i] = int.Parse(Console.ReadLine());
                    break;
                }
                catch (Exception)
                {
                    Console.Write("Please re-enter element:");
                }
            }
        }
        Console.Write("please enter the sum: ");
        do
        {
            while (true)
            {
                try
                {
                    givenSum = int.Parse(Console.ReadLine());
                    break;
                }
                catch (Exception)
                {
                    Console.Write("Please re-enter number:");
                }
            }
        } while (givenSum > lenght);






        Console.ReadLine();
    }
}

